<?php

namespace common\models\c2\statics;

use Yii;
use yii\helpers\ArrayHelper;

/**
 * ConfigType
 *
 * @author ben
 */
class MaterialType extends AbstractStaticClass {

    const TYPE_AD = 1;  // 登录广告
    const TYPE_SERVER = 2;  // 客服素材
    const TYPE_BANNER = 3;  // 首页广告
    const TYPE_AD1 = 4;  // 宝贝页广告
    const TYPE_AD2 = 5;  // 家人页广告

    protected static $_data;

    /**
     * 
     * @param string $id
     * @param string $attr
     * @return string|array
     */
    public static function getData($id = '', $attr = '') {
        if (is_null(static::$_data)) {
            static::$_data = [
                static::TYPE_AD => ['id' => static::TYPE_AD, 'label' => Yii::t('app.c2', 'Advertisement')],
                static::TYPE_SERVER => ['id' => static::TYPE_SERVER, 'label' => Yii::t('app.c2', 'Server')],
                static::TYPE_BANNER => ['id' => static::TYPE_BANNER, 'label' => Yii::t('app.c2', 'Banner')],
                static::TYPE_AD1 => ['id' => static::TYPE_AD1, 'label' => Yii::t('app.c2', 'AD1')],
                static::TYPE_AD2 => ['id' => static::TYPE_AD2, 'label' => Yii::t('app.c2', 'AD2')],
            ];
        }
        if ($id !== '' && !empty($attr)) {
            return static::$_data[$id][$attr];
        }
        if ($id !== '' && empty($attr)) {
            return static::$_data[$id];
        }
        return static::$_data;
    }

}
